aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/pages/kodaira/events/[period].astro
diff options
context:
space:
mode:
authorYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 14:58:06 +0900
committerYasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com>2026-11-05 14:58:06 +0900
commite7b60d5ef8c8cf5471a62498fd0a88f61cd2812e (patch)
tree7a7033fc634baa1d7695dd52e90961e98cfc5e16 /src/pages/kodaira/events/[period].astro
parent3e02a6a05c6a5b26fbb19fa91be9afbc6b12877d (diff)
events: メインは前月以降、アーカイブは前々月以前に分ける
メインページの一覧とカレンダーを前月以降に広げ、前々月以前の月だけを アーカイブとして生成するようにした。該当が無いときはアーカイブ欄に その旨を表示する。月が進めば自動でページが増える。 RSSと旧URLの転送先も、存在しない月ページを指さないよう合わせた。
Diffstat (limited to 'src/pages/kodaira/events/[period].astro')
-rw-r--r--src/pages/kodaira/events/[period].astro29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/pages/kodaira/events/[period].astro b/src/pages/kodaira/events/[period].astro
index 701d9e3..f2d03df 100644
--- a/src/pages/kodaira/events/[period].astro
+++ b/src/pages/kodaira/events/[period].astro
@@ -1,14 +1,14 @@
---
-// 月別・年度別アーカイブ(/kodaira/events/2026-11/、/kodaira/events/r8/ など)。
-// 行事予定のデータ(src/data/schedule/*.json)から、その期間の予定だけを静的に生成する。
+// 月別・年度別アーカイブ(/kodaira/events/2026-09/、/kodaira/events/r7/ など)。
+// 前々月以前の予定だけを静的ページにする(前月以降はメインページに載せる)。
import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
import ScheduleTable from '@/components/ScheduleTable.astro';
import {
- fiscalYearKeys,
+ archiveFiscalYearKeys,
+ archiveMonthKeys,
fiscalYearLabel,
fiscalYearOf,
monthCounts,
- monthKeys,
monthLabel,
monthsInFiscalYear,
rowsInFiscalYear,
@@ -18,22 +18,22 @@ import { SCHEDULE_BASE_PATH } from '@/data/schedule/config';
export function getStaticPaths() {
return [
- ...monthKeys.map((key, i) => ({
+ ...archiveMonthKeys.map((key, i) => ({
params: { period: key },
props: {
kind: 'month' as const,
key,
- prev: monthKeys[i - 1] ?? null,
- next: monthKeys[i + 1] ?? null,
+ prev: archiveMonthKeys[i - 1] ?? null,
+ next: archiveMonthKeys[i + 1] ?? null,
},
})),
- ...fiscalYearKeys.map((key, i) => ({
+ ...archiveFiscalYearKeys.map((key, i) => ({
params: { period: key },
props: {
kind: 'fiscal' as const,
key,
- prev: fiscalYearKeys[i - 1] ?? null,
- next: fiscalYearKeys[i + 1] ?? null,
+ prev: archiveFiscalYearKeys[i - 1] ?? null,
+ next: archiveFiscalYearKeys[i + 1] ?? null,
},
})),
];
@@ -58,6 +58,11 @@ const eventRows =
// 年度ページでは、その年度の月別ページへの一覧も並べる。
const months = kind === 'fiscal' ? monthsInFiscalYear(key) : [];
+// 月別ページから年度ページに戻れるのは、その年度のページが存在するときだけ。
+const fiscalYearForKey = kind === 'month' ? fiscalYearOf(key) : null;
+const hasFiscalPage =
+ fiscalYearForKey !== null && archiveFiscalYearKeys.includes(fiscalYearForKey);
+
const url = (period: string) => `${SCHEDULE_BASE_PATH}${period}/`;
// 期間がすべて過去か、すべて未来か、今日を含むかで説明文を変える。
@@ -133,9 +138,9 @@ const description = isAllPast
}
{
- kind === 'month' && (
+ kind === 'month' && hasFiscalPage && fiscalYearForKey && (
<p class="schedule-fiscal-link">
- <a href={url(fiscalYearOf(key))}>{fiscalYearLabel(fiscalYearOf(key))}の予定をまとめて見る</a>
+ <a href={url(fiscalYearForKey)}>{fiscalYearLabel(fiscalYearForKey)}の予定をまとめて見る</a>
</p>
)
}